import requests
import re

url = 'https://s.weibo.com/top/summary'
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 '
                  '(KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36'
}

html_response = requests.get(url, headers=headers)
html_content = html_response.content.decode('utf8')
"""
<td class="td-02">
    <a href="/weibo?q=%23%E5%BC%A0%E9%9B%AA%E8%BF%8E%E5%8F%91%E9%95%BF%E6%96%87%E5%9B%9E%E5%BA%94%E7%B2%89%E4%B8%9D%23&amp;Refer=top" target="_blank">张雪迎发长文回应粉丝</a>
<span>3661671</span>
</td>
"""
# 获取标题
title = re.findall(r'<td class="td-02">.*?<a.*?>(.*?)</a>', html_content, re.DOTALL)[1:]
# 热度
hots = re.findall(r'<td class="td-02">.*?<span>(.*?)</span>', html_content, re.DOTALL)
hot_search = []
for title, hots in zip(title, hots):
    temp_dict = {
        'title': title,
        'hots': hots
    }
    hot_search.append(temp_dict)

print(hot_search)

